﻿Public Class frmPruebasDiesel

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With commUSB
            If .IsOpen Then
                .Close()
            End If

            .PortName = "COM3"
            .BaudRate = 57600
            .DataBits = 8
            .StopBits = IO.Ports.StopBits.One
            .Parity = IO.Ports.Parity.None
            .DtrEnable = False
            .Handshake = IO.Ports.Handshake.None
            .ReadBufferSize = 4096
            .WriteBufferSize = 2048
            .ReceivedBytesThreshold = 1
            .WriteTimeout = -1
            .Encoding = System.Text.Encoding.Default
            .Open()
        End With

        'BorraTotal(1)
        'Dim a As Short
        'a = PrefijarLitros(1, Val(100))
        'Timer1.Enabled = True
        'litsur01.Text = 100
        'venta01.Text = "x"

        venta01.Text = LeerPrecio(1)

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim precio As Double
        Dim tventa As Double
        Dim lugar As String
        Dim Título As String
        Dim Estilo As Integer
        Dim Mensaje As String
        Dim LecturaVenta As Double
       
        Mensaje = "Dispensario Ocupado"
        Estilo = MsgBoxResult.Yes
        Título = "Información" ' Define el título.
        lugar = "DIESEL   " & nomofna
        LecturaVenta = VentaLitros(1) '-999999
        If Val(venta01.Text) = LecturaVenta And LecturaVenta > 0 And txtVta1.Text = "00" Then
            If Not IsNumeric(ter01.ADMIN) Then
                ter01.ADMIN = 0
            End If
            tventa = Val(venta01.Text)
            precio = LeerPrecio(1)
            While precio < 0
                precio = LeerPrecio(1)
            End While
            Rendimiento_1 = Distancia_1 / tventa
            Timer1.Enabled = False
            Else
            If Math.Abs(Val(txtVta1.Text)) <> Math.Abs(LecturaVenta) And Trim(Str(LecturaVenta)) <> "-1" Then
                venta01.Text = Str(LecturaVenta)
                txtVta1.Text = "00"
            End If
        End If

    End Sub

    Private Sub frmPruebasDiesel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class